package DB;

import java.util.ArrayList;


/**
 * class that holds all of the changes in the server DB in Chronological order
 * the changes will be saved in an array and new changes will be added at the end
 * changes can be only of three types: "created filename","deleted filename", "renamed oldfilename newfilename"
 * @author Erez
 * 
 */

public class ArrayOfChanges {
	ArrayList<String> arrayList;
	
	public static ArrayOfChanges instance = new ArrayOfChanges();
	
	
    /**
     * private constructor , the class is a singletone
     */

	private ArrayOfChanges(){
		arrayList = new ArrayList<String>();
		//for the first one
		
		arrayList.add(null);
		arrayList.add("created add.txt");
		arrayList.add("created rrrrrrrr.txt");
	}
	
    /**
     * adding change at the end of the array
     * @param change the string that represent a change
     */

	public void addChange(String change){
		arrayList.add(change);
	}
	
    /**
     * returning the last string in the change array
     * @return String 
     */

	public String lastChange(){
		return arrayList.get(arrayList.size()-1);
	}
	
	
    /**
     * returning the i change in the array
     * @param i index of the string to get in the array
     * @return String that represent the change
     */

	public String changeInIndex(int i){
		return arrayList.get(i);
	}
	
    /**
     * returning the last index in the array
     * @return int that is the last index of array
     */
	public int lastIndex(){
		return arrayList.size()-1;
	}
	
	
}
